<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script type="text/javascript" src="../js/vue.js"></script>
</head>

<body>
    <div id="root">
        <school></school>
        <hello></hello>
    </div>

    <script type="text/javascript">

        const school = Vue.extend({
            template: `
                <div>
                    <h2>学校名称：{{schoolName}}</h2>
                    <h2>学校地址：{{address}}</h2>
                    <button @click="showName">点我提示学校名</button>
                </div>
            `,
            data: function () {
                return {
                    schoolName: '尚硅谷',
                    address: '北京昌平'
                }
            },
            methods:{
                showName(){
                    console.log(this)
                }
            }
        })

        const hello = Vue.extend({
            name: 'hello',
            template: `
                <div>
                    <h2>{{sql}}</h2>
                </div>
            `,
            data: function () {
                return {
                    sql: '你好啊'
                }
            }
        })

        const vm = new Vue({
            el: '#root',
            components: {
                school,
                hello
            }
        })
    </script>

</body>

</html>